package com.android;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class Database extends SQLiteOpenHelper
{
	//starting constants for the database
	public static final String ColTime = "Time";
	public static final String DBname = "database_x";
	public static final String TABLEname = "highscore";
	public static final String ColName = "Name";
	public static final String ColTurns = "Turns";
	public static final Integer DBversion = 1;
	//used for deleting the database
	public Context context;


	public Database(Context context) {
		super(context, DBname, null, DBversion);
		this.context = context;
		// TODO Auto-generated constructor stub
	}
	
	public void deleteDB(){
		//deletes the database named database_x
		context.deleteDatabase(DBname);
	}
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		//creates the table like this:
		//|string| tablename
		//|string|int|int| name,time,turns
		String sql_HighScore = String.format("create table %s (%s TEXT primary key, %s INT, %s INT)",TABLEname, ColName, ColTime, ColTurns);
		//execute it
		db.execSQL(sql_HighScore);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}
}